const mongoose = require('mongoose');
mongoose.connect('mongodb+srv://mgold6736:54TNrmB0Y2reoZ8r@cluster0.dyeaoht.mongodb.net/zzz')
.then(() => console.log('Connected to MongoDB'))
.catch(err => console.log(err));

const yh=mongoose.Schema({
    name:String,
    age:Number,
    password:String,
    email:String
})

const yh1=mongoose.model('yh1',yh,'yh1')

// 聊天记录 Schema
const ChatSchema = new mongoose.Schema({
    from: String,
    to: String,
    message: String,
    timestamp: Date,
    read: { type: Boolean, default: false }
});

const Chat = mongoose.model('Chat', ChatSchema, 'chat');

// 单方面清除聊天记录 Schema
const deleteMarkSchema = mongoose.Schema({
    user: String,         // 谁清除的
    peer: String,         // 和谁的会话
    deletedBefore: Date   // 清除到的时间
});

const DeleteMark = mongoose.model('DeleteMark', deleteMarkSchema, 'delete_mark');
const fuanyuanSchema = new mongoose.Schema({
    text:String,
    types:String,
    price:Number,
    status:{
        type:Boolean,
        default:false,
    },
    address:String,
    lei:String,
    mains:String,
    fanw:String,
    ceng:String,
    cz:{
        type:Boolean,
        default:false,
    }
})
const fuanModel = mongoose.model('fuan',fuanyuanSchema,'fuan')
module.exports = { yh1, Chat, DeleteMark ,fuanModel};

